package com.yd.basemodule.interceptor

import okhttp3.Interceptor
import okhttp3.Response

/**
 * <pre>
 *     author : yh
 *     e-mail : xxx@xx
 *     time   : 2022/01/06
 *     desc   :
 * </pre>
 */
class BaseInterceptor(private val headers:Map<String,String>?):Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        return chain.proceed(chain.request().newBuilder().run {
            if (!headers.isNullOrEmpty()){
                for (headMap in headers){
                    addHeader(headMap.key, headMap.value).build()
                }
            }
            build()
        })
    }

}